home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Cream of the Crop 21
/
Cream of the Crop 21 (Terry Blount) (October 1996).iso
/
program
/
lxtw109.zip
/
LXT.CB
< prev
next >
Wrap
Text File
|
1996-08-03
|
44KB
|
1,262 lines
/*****************************************************************************/
/*
LXT.CB - BRIEF MACRO FUNCTIONS FOR
LFTN (TM) LISP FUNCTION TREE NAVIGATOR
Copyright (C) Juergen Mueller (J.M.) 1992-1996
All rights reserved.
You are expressly prohibited from selling this software in any form,
distributing it with another product, or removing this notice.
Limited permission is given to registered LXT users to modify this
file for their own personal use only. This file may not be used for any
purpose other than in conjunction with the LXT software package.
THIS SOFTWARE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND,
EITHER EXPRESSED OR IMPLIED, INCLUDING, WITHOUT LIMITATION, THE
IMPLIED WARRANTIES OF MERCHANTIBILITY OR FITNESS FOR A PARTICULAR
PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE
PROGRAM AND DOCUMENTATION IS WITH YOU.
written by: Juergen Mueller, Aldingerstrasse 22, D-70806 Kornwestheim,
GERMANY
FILE : LXT.CB
REVISION : 27-Apr-1996
18:31:27
*/
/*****************************************************************************/
#include "dialog.h" /* include file from original BRIEF DIALOG menus */
/*****************************************************************************/
/* defines */
/*****************************************************************************/
#define TMPFILE "LXTFILE.TMP"
#define LFTNPROG "lftn" /* or "lftn4os2" for OS/2 */
/* or "lftn32" for Windows NT / Windows 95 */
#ifdef __OS2__
#define upper(x) (x)
#endif
/*****************************************************************************/
/**** USER macro function prototypes ****/
/*****************************************************************************/
void lft(void);
void lftfind(void);
void lftmenu(void);
void lftbase(void);
void lftfilemenu(void);
void lftxrefmenu(void);
void lftxrefmenuagain(void);
void lftdefmenu(void);
/*****************************************************************************/
/**** INTERNAL macro function prototypes ****/
/*****************************************************************************/
void _init(void); /* initialisation function, called on entry */
void _lxtmenu_exit(void);
void _exec_error(int retval, string format, string par1, string par2);
string _extract_item(void);
void _lxt(string, string);
void _lxt_search(string, string, string, int, int);
void _lxt_edit_file(void);
void _lxt_locate(void);
void _lxt_buffers(void);
void _lxtmenu(string, string);
int _lft_action(int, ...);
void _lxtfilemenu(string, string);
int _lxt_fileaction(int, ...);
void _lxtxrefmenu(string, string, int);
int _lxt_xrefaction(int, ...);
void _lxtdefmenu(string, string);
int _lxt_defaction(int, ...);
void _lxt_insert_sorted(string, int, int);
/*****************************************************************************/
/**** global variables ****/
/*****************************************************************************/
string lft_base; /* data base name for lft */
string lxt_loc; /* resulting file with item location */
string lxt_item; /* item to search for */
int lxt_id; /* item id */
string lxt_file; /* target file name */
int lxt_line; /* target line, used by registered macro */
string lft_loc; /* resulting file for menu */
int lft_menuwidth; /* horizontal lft menu width */
string lft_files; /* resulting file for filemenu */
int lft_filemenuwidth; /* horizontal lft filemenu width */
string lft_xref;
string lft_xref_item;
int lft_xrefmenuwidth;
string lft_deffile;
string lft_def_item;
int lft_defmenuwidth;
/*****************************************************************************/
/**** macro package initialization function ****/
/*****************************************************************************/
void _init(void)
{
/* init LFT base with environment */
lft_base = trim(ltrim(inq_environment("LFTNBASE")));
lxt_loc = "lxt.loc"; /* intermediate file for search results */
lft_loc = "lft.loc"; /* used for function menu */
lft_files = "lft_file.loc"; /* used for function file menu */
lft_xref = "lft_xref.loc";
lft_xref_item = "";
lft_deffile = "lft_def.loc";
lft_def_item = "";
/* register macro to delete temporary files on exit from BRIEF */
register_macro(5, "_lxtmenu_exit");
}
/*****************************************************************************/
/* registered macro to perform actions on exit of BRIEF or */
/* if changes of database names have happened */
/*****************************************************************************/
void _lxtmenu_exit(void)
{
if (exist(lft_loc))
del(lft_loc);
if (exist(lft_files))
del(lft_files);
if (exist(lft_xref))
del(lft_xref);
if (exist(lft_deffile))
del(lft_deffile);
}
/*****************************************************************************/
/**** user callable macros ****/
/*****************************************************************************/
void lft(void) /* find function */
{
_lxt(LFTNPROG, lft_base); /* do function retrieval */
}
void lftfind(void) /* find user defined item */
{
string item;
get_parm(NULL, item, "LFT function name: ", 50);
item = compress(trim(ltrim(item)));
if (strlen(item))
_lxt_search(LFTNPROG, lft_base, item, 0, 0);
}
void lftmenu(void) /* build function menu */
{
_lxtmenu(LFTNPROG, lft_base);
}
void lftbase(void) /* set LFT database name */
{
get_parm(NULL, lft_base, "LFT database name: ", 50, lft_base);
lft_base = trim(ltrim(lft_base));
_lxtmenu_exit(); /* delete menu files */
}
void lftfilemenu(void) /* build LFT file menu */
{
_lxtfilemenu(LFTNPROG, lft_base);
}
void lftxrefmenu(void) /* build function cross reference menu */
{
_lxtxrefmenu(LFTNPROG, lft_base, 1);
}
void lftxrefmenuagain(void) /* rebuild menu for previous item */
{
_lxtxrefmenu(LFTNPROG, lft_base, 0);
}
void lftdefmenu(void)
{
_lxtdefmenu(LFTNPROG, lft_base);
}
/*****************************************************************************/
/**** internal macro execution functions ****/
/*****************************************************************************/
/*****************************************************************************/
/* */
/*****************************************************************************/
void _exec_error(int retval, string format, string par1, string par2)
{
if (retval >= 100)
message(format, par1, par2);
else
message("Command execution error (%d)", retval);
}
/*****************************************************************************/
/* read search item from current buffer */
/*****************************************************************************/
string _extract_item(void)
{
int move_flag, markval, marklen;
int start_line, start_col, end_line, end_col;
string itemname, act_char, tmp_char, fchar, nchar;
fchar = "[$_a-zA-Z]"; /* first character of an identifier */
nchar = "[$_a-zA-Z0-9\\-]"; /* not first character of an identifier */
if (!(markval = inq_marked(start_line, start_col, end_line, end_col)))
{ /* nothing marked, use cursor position */
if (!search_string(nchar, read(1)))
{
message("Invalid cursor position");
return "";
}
save_position(); /* save the current position */
act_char = read(1); /* read current character */
whi